package com.huashi.dealer.commonEntity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 配送模板区域及运费实体类
 */
@Getter
@Setter
@TableName("yoshop_delivery_rule")
@Schema(description = "配送模板区域及运费实体")
public class DeliveryRule {

    @TableId(value = "rule_id", type = IdType.AUTO)
    @Schema(description = "规则ID")
    private Long ruleId;

    @TableField("delivery_id")
    @Schema(description = "配送模板ID")
    private Long deliveryId;

    @TableField("region")
    @Schema(description = "区域（逗号分隔）")
    private String region;

    @TableField("first")
    @Schema(description = "首件/首重")
    private Integer first;

    @TableField("first_fee")
    @Schema(description = "首件/首重费用")
    private BigDecimal firstFee;

    @TableField("additional")
    @Schema(description = "续件/续重")
    private Integer additional;

    @TableField("additional_fee")
    @Schema(description = "续件/续重费用")
    private BigDecimal additionalFee;

    @TableField("is_delete")
    @TableLogic
    @Schema(description = "软删除标记")
    private Integer isDelete;

    @TableField("create_time")
    @Schema(description = "创建时间")
    private Long createTime;

    /**
     * 获取区域数据数组
     */
    @JsonProperty("regionData")
    public String[] getRegionData() {
        return region != null ? region.split(",") : new String[0];
    }
} 